Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display sent and received txs in a single table #1167

Merged
merged 29 commits into from
Oct 19, 2023

Conversation

brtkx
Copy link
Contributor

@brtkx brtkx commented Sep 22, 2023

In preparation for single tx history table, we merge 'sent' and 'received' tabs into one table.

We achieve this by using 'or' clause in the subgraph query. Event logs had to also be slightly modified to make 2 calls (sent and received) and be merged together.

A lot of old stuff got removed.

Testing

You should be able to see transactions sent by your address and received by your address in a single table, without the need for 'sent' and 'received' tabs.

Note that CCTP is still in its own tab. We will also merge it with other txs in a separate PR.

@cla-bot cla-bot bot added the cla-signed label Sep 22, 2023
@vercel
Copy link

vercel bot commented Sep 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
arbitrum-token-bridge ✅ Ready (Inspect) Visit Preview Oct 18, 2023 5:57pm

@brtkx brtkx changed the title refactor: display sent and received txs in a single table fix: display sent and received txs in a single table Sep 22, 2023
@brtkx brtkx marked this pull request as ready for review September 25, 2023 11:51
@brtkx brtkx marked this pull request as draft September 27, 2023 16:29
@brtkx brtkx marked this pull request as ready for review October 2, 2023 10:40
@fionnachan fionnachan self-requested a review October 3, 2023 17:14
@dewanshparashar dewanshparashar self-requested a review October 3, 2023 19:21
Copy link
Member

@fionnachan fionnachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@@ -235,18 +229,6 @@ export function TransactionsTable({
return [...newerTransactions.reverse(), ...subgraphTransactions]
}, [transactions, localTransactionsKey])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Hook useMemo has missing dependencies: 'locallyStoredTransactions', 'pageParams.pageNumber', 'pageParams.searchString', and 'type'. Either include them or remove the dependency array.eslintreact-hooks/exhaustive-deps

do we need the other deps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't had them before but I will have a look.

Maybe @dewanshparashar can have a look as well as I don't believe I've made any changes here before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In dependencies,

  • we don't need locallyStoredTransactions since this state object mutates very frequently and localTransactionsKey (string) is derived from it to keep things under control.
  • pageNumber and searchString can be added, but we only need this memo function to run for the very first page so adding these doesn't make a difference to the logic / result. Just that it will recalculate and do an early return for each update. It's optional.

If we go ahead with it, I'd suggest a different PR to isolate it's impact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need locallyStoredTransactions since this state object mutates very frequently and localTransactionsKey (string) is derived from it to keep things under control.

Then we should either memo it, or not having it as a dependencies, otherwise it make things unpredictable

pageNumber and searchString can be added, but we only need this memo function to run for the very first page so adding these doesn't make a difference to the logic / result. Just that it will recalculate and do an early return for each update. It's optional.

If they are part of the callback of useEffect, then they should be included, even if they never change

packages/arb-token-bridge-ui/src/hooks/useDeposits.ts Outdated Show resolved Hide resolved
packages/arb-token-bridge-ui/src/hooks/useWithdrawals.ts Outdated Show resolved Hide resolved
return fromBlockParam + toBlockParam + searchParam
}

export const dedupeEvents = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this only used in one place? Let's move it there then

partialTokenWithdrawalsFromEventLogs.map(withdrawal =>
const mappedTokenWithdrawalsFromEventLogs = await Promise.all(
paginatedWithdrawalsFromEventLogs
.filter(withdrawal => !isEthWithdrawal(withdrawal))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't see why this is necessary, as we should already know if something's an eth withdrawal or a token withdrawal. So we can do the mapping first before we put them all together into a single array and then we don't need this check

]
.reverse()
.sort((a, b) => (a.timestamp?.gt(b.timestamp || constants.Zero) ? -1 : 1))
Copy link
Member

@spsjvc spsjvc Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have another instance of sorting by timestamp in this file. So let's extract to a function and also mention that it's descending (if I'm not mistaken):

type Timestamped = { 
  timestamp?: BigNumber
}

function sortByTimestampDescending(a: Timestamped, b: Timestamped) {
  const aTimestamp = a.timestamp ?? constants.Zero
  const bTimestamp = b.timestamp ?? constants.Zero

  return aTimestamp.gt(bTimestamp) ? -1 : 1
}

// later
something.sort(sortByTimestampDescending)

Copy link
Member

@fionnachan fionnachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested tx history panel with goerli Safe, arb goerli Safe, goerli EOA, and arb goerli EOA, all look good

@fionnachan fionnachan enabled auto-merge (squash) October 18, 2023 17:56
@fionnachan fionnachan disabled auto-merge October 18, 2023 17:56
@brtkx brtkx merged commit 888352d into master Oct 19, 2023
22 checks passed
@brtkx brtkx deleted the or-condition-subgraph branch October 19, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants